#!/usr/bin/python
# -*- coding: utf-8 -*-

import psycopg2 as pcg

try:
    pg_conn = pcg.connect(database='test', user='postgres',
                          password='root', host='127.0.0.1')
    pg_cursor = pg_conn.cursor()
    sql_sec = "select * from person"
    pg_cursor.execute(sql_sec)
    for row in pg_cursor:
        print row
except Exception, e:
    print e.args[0]

pg_conn.close()
